package app.page;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import org.openqa.selenium.By;

import java.util.concurrent.TimeUnit;

public class PersonPage extends BasePage {

    // add person
    By addPerson = By.cssSelector("*[text='添加成员']");
    By inputByManual = By.cssSelector("*[text='手动输入添加']");
    By name = By.xpath("(//android.widget.EditText)[1]");
    By number = By.xpath("(//android.widget.EditText)[2]");
    By isSendMsg = By.cssSelector("*[text*='邀请']");
    By save = By.cssSelector("*[text*='保存']");
    By back = By.xpath("(//android.widget.TextView)[1]");
    By close = By.xpath("(//android.widget.TextView)[3]");

    // add department
    By addDept = By.cssSelector("*[text='添加子部门']");
    By deptName = By.xpath("//android.widget.EditText");
    By ok = By.cssSelector("*[text*='确定']");

    public PersonPage(AppiumDriver<MobileElement> driver) {
        super(driver);
    }

    public ContactPage addPerson(String name, String no) {
        click(addPerson);
        click(inputByManual);
        sendKeys(this.name, name);
        sendKeys(number, no);
        click(isSendMsg);
        click(save);
        click(back);
        click(close);
        return new ContactPage(driver);
    }

    public ContactPage addDept(String name) {
        click(addDept);
        sendKeys(deptName, name);
        click(ok);
        click(close);
        return new ContactPage(driver);
    }
}
